package com.functionx.dto;

public class MonitoringDto {

    public static final Double[] whole_bounds = new Double[]{3.3, 73.28, 53.34, 135.3};

    public static final double det_lat = 0.178;

    public static final double det_lon = 0.211;

    private String aqi;

    private String city;

    private int idx;

    private String img;

    private double lat;

    private double lon;

    private String pol;

    private long stamp;

    private String tz;

    private String utime;

    private String x;

    private double distance;

    public int getAqi() {
        if (aqi.matches("\\d+"))
            return Integer.valueOf(aqi);
        else
            return 0;
    }

    public void setAqi(String aqi) {
        this.aqi = aqi;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public int getIdx() {
        return idx;
    }

    public void setIdx(int idx) {
        this.idx = idx;
    }

    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public double getLat() {
        return lat;
    }

    public void setLat(double lat) {
        this.lat = lat;
    }

    public double getLon() {
        return lon;
    }

    public void setLon(double lon) {
        this.lon = lon;
    }

    public String getPol() {
        return pol;
    }

    public void setPol(String pol) {
        this.pol = pol;
    }

    public long getStamp() {
        return stamp;
    }

    public void setStamp(long stamp) {
        this.stamp = stamp;
    }

    public String getTz() {
        return tz;
    }

    public void setTz(String tz) {
        this.tz = tz;
    }

    public String getUtime() {
        return utime;
    }

    public void setUtime(String utime) {
        this.utime = utime;
    }

    public String getX() {
        return x;
    }

    public void setX(String x) {
        this.x = x;
    }

    public double getDistance() {
        return distance;
    }

    public void setDistance(double distance) {
        this.distance = distance;
    }

    @Override
    public int hashCode() {
        return code(lat, lon);
    }

    public static int code(double lat, double lon) {
        double detLat = lat - whole_bounds[0];
        double detLon = lon - whole_bounds[1];
        return (int) (detLat / det_lat) + (int) (detLon / det_lon) * 1000;
    }

    @Override
    public boolean equals(Object obj) {
        MonitoringDto monitoringDto = (MonitoringDto) obj;
        return Double.compare(lat, monitoringDto.lat) == 0 && Double.compare(lon, monitoringDto.lon) == 0;
    }
}
